
<template>
  <el-form ref="dataForm" :rules="rules" :model="form">
    <el-form-item required label-width="120px" label="删除原因" prop="modReason">
      <el-input  width="100%"  type="textarea" v-model="form.modReason" placeholder="删除原因"></el-input>
    </el-form-item>
    <el-form-item class="btnDir">
      <el-button @click="onSubmit">确 定</el-button>
      <el-button @click="onCancel">取 消</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
import requestUtil from '@/utils/requestEnc';
import CustOrderService from "@/api/order/CustOrderService";
import { mapState } from "vuex";
export default {
 components: {
		requestUtil,
		CustOrderService,
  },
  computed: {
		...mapState("orders", ["orderItemList"]),
		...mapState("user", ["user"]),
	},
  async mounted(){

  },
  watch:{

  },
  props:{
	  	ODKInfo: {
			type: Object,
			default: () => {
				return {};
			},
		},
		CTOInfo: {
			type: Array,
			default: () => {
				return [];
			},
		},
  },
  data() {
    return {
      form:{
          modReason:"",
      },
      reFee:"",
      valueRadio:"",
      orderTask:{},
      orderItemIds:"",
      rules:{
        modReason:[
           { required: true, message: '删除原因不能为空', trigger: 'blur' },
        ]
      }
    }
  },
  methods: {
    onCancel(){
      this.$emit('update:show',false)
    },
    async onSubmit(){

      
      this.$refs["dataForm"].validate((valid) => {
        if (valid) {
          
          this.submit();
        } else {
          
          return false;
        }
      });

     
    },
    async submit(){

        if(this.form.modReason != '' && this.form.modReason != null){
            this.form.modReason = this.form.modReason.replace(/[^\x00-\xff]/g,'**');
        }

        if(this.form.modReason.length > 1000){
          	this.$confirm("字符长度最大不能超过1000", "提示", {
								confirmButtonText: "确定",
								showCancelButton: false,
								type: "warn",
								center: true
                });
                return;
        }

        var reqMap = this.ODKInfo.reqMap;
        reqMap.modReason = this.form.modReason;
        
        if(this.ODKInfo.deleteType == "delProdOffer"){
          var result  = await CustOrderService.delProdOffer(reqMap);
        }else if(this.ODKInfo.deleteType == "deleteCustOrder"){
          var result = await CustOrderService.deleteCustOrder(reqMap);
        }else if(this.ODKInfo.deleteType == "delOrder"){
          var result = await CustOrderService.delOrder(reqMap);
        }
					
					if(result.meta && result.meta.resultCode == "0"){
							this.$confirm("删除成功", "提示", {
								confirmButtonText: "确定",
								showCancelButton: false,
								type: "success",
								center: true
                });
                this.$emit("close");
					}else{
						this.$confirm(result.meta, "提示", {
								confirmButtonText: "确定",
								showCancelButton: false,
								type: "warn",
								center: true
                });
              
					}
    }
  }
};
</script>

<style>
.el-form--inline .el-form-item {
  display: inline-flex;
  margin-right: 0.1rem;
  vertical-align: top;
  width: 42%;
}

.el-form-item__label {
  width: 94px;
}
.btnDir {
  margin-left: 36%;
  margin-top: 19px;
}
</style>
